This is an R Markdown Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the Run button within the chunk or by placing your cursor inside it and pressing Ctrl+Shift+Enter.
dir_prj <- "G:/Github/phenology/phenofit" setwd(dir_prj) source('inst/shiny/check_season/global.R') source("test/stable/load_pkgs.R") source("test/phenology_async/R/s1_materials/main_phenofit.R") load("data_test/phenoflux115_gs.rda")
test one site first
sitename <- c("AU-Stp", "IT-Noe", 'US-Syv', 'US-WCr')[1]#,"CA-Man" d <- df[site == sitename, .(t = date, GPP_DT, GPP_NT, w = 1)] #%T>% plotdata(365) d$y <- rowMeans(d[, .(GPP_DT, GPP_NT)], na.rm = T) d[y < 0, y := 0] # for GPP_NT sp <- st[site == sitename, ] # parameters for season_3y threshold_max = 0.1 nf = 1 INPUT <- get_input(df, st, sitename) wFUN <- wTSM i <- grep(sitename, sites) brks2 <- brks_lst[[i]] fit <- curvefits(INPUT, brks2, methods = c("AG", "zhang", "beck", "elmore"), #,"klos",, 'Gu' debug = F, wFUN = wFUN, nextent = 5, maxExtendMonth = 3, minExtendMonth = 1/3, qc = as.numeric(dnew$SummaryQA), minPercValid = 0.2, print = print) fit$INPUT <- INPUT fit$seasons <- brks2 ## check the curve fitting parameters params <- getparam(fit) print(str(params, 1)) print(params$AG) ## Get GOF information stat <- ldply(fit$fits, function(fits_meth){ ldply(fits_meth, statistic.phenofit, .id = "flag") }, .id = "meth") fit$stat <- stat print(head(stat)) # print(fit$fits$AG$`2002_1`$ws) ## visualization # svg("Figure1_phenofit_curve_fitting.svg", 11, 7) # Cairo::CairoPDF(file_pdf, 11, 6) # # dev.off() g <- plot_phenofit(fit, d, INPUT$titlestr) grid::grid.newpage(); grid::grid.draw(g)# plot to check the curve fitting
source("test/phenology_async/R/s1_materials/main_phenofit.R") debug <- T if (debug){ sites0 <- c("AU-Stp", "IT-Noe", 'US-Syv', 'US-WCr') subfix <- "_part" } else { sites0 <- st$site subfix <- "" } file <- sprintf("Figures3_phenofit_GPPobs_v0.1.1.pdf", subfix) CairoPDF(file, 12, 7) fits <- llply(sites0, get_phenofit, df, st, brks_lst, sites, wFUN = 'wTSM', .progress = "text") dev.off() # fit <- get_phenofit(i, df, st, brks_lst, sites, 'wTSM')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.